package com.bangdao.app.jetpacktest.jetpack.databinding;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import com.bangdao.app.jetpacktest.R;
import com.bangdao.app.jetpacktest.databinding.ActivityTwoWayDataBinding5Binding;
import com.bangdao.app.jetpacktest.jetpack.databinding.viewmodel.TwoWayBindingViewModel5;

/**
 * 双向绑定
 */
public class TwoWayDataBindingActivity5 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        //创建DataBinding
        ActivityTwoWayDataBinding5Binding binding =
                DataBindingUtil.setContentView(this, R.layout.activity_two_way_data_binding5);
        //创建ViewModel
        TwoWayBindingViewModel5 viewModel5 = new ViewModelProvider(this).get(TwoWayBindingViewModel5.class);
        ////建立绑定关系
        binding.setViewModel(viewModel5);
    }
}